package com.ruitu.health_2.mvp.model;

import com.ruitu.arad.api.RxUtil;
import com.ruitu.arad.base.BaseModel;
import com.ruitu.health_2.dao.http.APIRetrofit;
import com.ruitu.router_module.bean.BaseResult2;
import com.ruitu.router_module.bean.PageModel2;
import com.ruitu.router_module.bean.order.ConfirmOrder;
import com.ruitu.router_module.bean.product.Coupon;
import com.ruitu.router_module.bean.product.ProDetail;
import com.ruitu.router_module.bean.product.ProHome;
import com.ruitu.router_module.bean.product.Sku;
import com.ruitu.router_module.bean.system.Common;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.RequestBody;

public class ProductModel {

    public static class ProGridM extends BaseModel {

        public Observable<BaseResult2<PageModel2<ProHome>>> reqProListByName(int size, int num, String name) {
            return APIRetrofit.getDefault()
                    .reqProListByName(size, num, name)
                    .compose(RxUtil.<BaseResult2<PageModel2<ProHome>>>subIoObMain());
        }

        public Observable<BaseResult2<PageModel2<ProHome>>> reqProListByColumn(int size, int num, String columnId) {
            return APIRetrofit.getDefault()
                    .reqProListByColumn(size, num, columnId)
                    .compose(RxUtil.<BaseResult2<PageModel2<ProHome>>>subIoObMain());
        }
    }

    public static class ProDetailM extends BaseModel {

        public Observable<BaseResult2<ProDetail>> reqProDetail(String id) {
            return APIRetrofit.getDefault()
                    .reqProDetail(id)
                    .compose(RxUtil.<BaseResult2<ProDetail>>subIoObMain());
        }

        public Observable<BaseResult2<List<Sku>>> reqSkuList(String pid) {
            return APIRetrofit.getDefault()
                    .reqSkuList(pid)
                    .compose(RxUtil.<BaseResult2<List<Sku>>>subIoObMain());
        }

        public Observable<BaseResult2<String>> reqAddToCart(RequestBody body) {
            return APIRetrofit.getDefault()
                    .reqAddToCart(body)
                    .compose(RxUtil.<BaseResult2<String>>subIoObMain());
        }

        public Observable<BaseResult2<ConfirmOrder>> reqBuyNow(
                String uId, String pId, String type, String skuId, String buyNum) {
            return APIRetrofit.getDefault()
                    .reqBuyNow(uId, pId, type, skuId, buyNum)
                    .compose(RxUtil.<BaseResult2<ConfirmOrder>>subIoObMain());
        }

        public Observable<BaseResult2<Common>> reqAddCollect(RequestBody body) {
            return APIRetrofit.getDefault()
                    .reqAddCollect(body)
                    .compose(RxUtil.<BaseResult2<Common>>subIoObMain());
        }

        public Observable<BaseResult2<String>> reqDelCollect(RequestBody body) {
            return APIRetrofit.getDefault()
                    .reqDelCollect(body)
                    .compose(RxUtil.<BaseResult2<String>>subIoObMain());
        }
    }

    public static class CouponListM extends BaseModel {

        public Observable<BaseResult2<PageModel2<Coupon>>> reqCouponList(int size, int num) {
            return APIRetrofit.getDefault()
                    .reqCouponList(size, num)
                    .compose(RxUtil.<BaseResult2<PageModel2<Coupon>>>subIoObMain());
        }

        public Observable<BaseResult2<String>> reqGetCoupon(RequestBody body) {
            return APIRetrofit.getDefault()
                    .reqGetCoupon(body)
                    .compose(RxUtil.<BaseResult2<String>>subIoObMain());
        }
    }
}
